import {Pipe, PipeTransform} from '@angular/core';
import {DictService} from '../service/dict.service';
import {Observable} from 'rxjs';

/**
 * 描述：处理获取字典集合,实时，无缓存
 * 作者：xc
 * 时间：2020-08-13 10:33
 */
@Pipe({
  name: 'dictList'
})
export class DictListPipe implements PipeTransform {

  constructor(private dictService: DictService) {
  }

  transform(dictType: string, options?: Array<any>): any {
    if (options) {
      return new Observable((observer) => {
        observer.next(options);
      });
    } else {
      return this.dictService.getCacheAndDictListByType(dictType);
    }
  }
}
